<?php

if(isset($_POST['createAuth'])){
	
	if(isset($_GET['action']) && $_GET['action'] == "add"){
		
		foreach($_POST as $key => $value){
			
			if($key == "clientname" || $key == "extension" || $key == "createAuth"){

				continue;
				
			}
			
			if(empty($value)){
				$_SESSION['error']['websitecreate'] = "Error: Please enter required information";
				break;
			}
			$wArr[$key] = $value;
			
		}
		
		if(empty($_SESSION['error']['websitecreate'])){
			$wArr['longname'] = "www.".$wArr['longname'].$lpcp->getLPCPWebsite()->getExtensions($_POST['extension']);
			$businessArr = $lpcp->getLPCPBusiness()->getShortname($session->getLPCPUser()->bid());
			$wArr['owner'] = $businessArr['shortname'];
			$wArr['cid'] = $lpcp->getCID($_POST['clientname']);
			
			//print_r($wArr);
	
			if($lpcp->getLPCPWebsite()->createWebsite($wArr)){
				
				$success = 'created';
				
			}else{
				
				$_SESSION['error']['websitecreate'] = "Error: Could not create new website";
				
			}
		}

	}
	
}


	if(isset($_SESSION['error']['websitecreate']) && !empty($_SESSION['error']['websitecreate'])){
		
		print "<i id='error'>".$_SESSION['error']['websitecreate']."</i>";
		unset($_SESSION['error']);
		
	}
	
	if($success){
		print "<i id='success'>Successfully ".$success." new website!</i>";
		unset($success);
		
	}

?>